﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using StockholmsStad.Windows.UI.Infrastructure;

namespace StockholmsStad.Windows.UI.Controls
{
    /// <summary>
    /// Interaction logic for NameValueField.xaml
    /// </summary>
    public partial class NameValueControl
    {
        //public string Label { get; set; }
        //public string Text { get; set; }

        public NameValueControl()
        {
            InitializeComponent();

            SetupBindings();
        }

        private void SetupBindings()
        {
            var labelContentBinding = new Binding("Label");
            labelContentBinding.Source = this;
            label.SetBinding(System.Windows.Controls.Label.ContentProperty, labelContentBinding);

            var tbTextBinding = new Binding("Text");
            tbTextBinding.Source = this;
            textBox.SetBinding(TextBox.TextProperty, tbTextBinding);
        }

        public static DependencyProperty LabelProperty =
            DependencyProperty.Register("Label", typeof(string), typeof(NameValueControl));

        public static DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(NameValueControl));

        public string Label
        {
            get { return (string)GetValue(LabelProperty); }
            set { SetValue(LabelProperty, value); }
        }

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public new string ToolTip { get; set; }

        private void OnInitialize(object sender, System.EventArgs e)
        {
            gridLabelColumn.Width = new GridLength(Position.ColumnLabelWidth);
        }
    }
}
